package com.ht.ui;

import javax.help.CSH;
import javax.help.HelpBroker;
import javax.help.HelpSet;
import javax.swing.*;
import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2011-3-29
 */
public class HelpTest {
    public static void main(String[] args) {
        JMenuItem menuItem = new JMenuItem("help");
        HelpSet mainHS = null;
        HelpBroker mainHB;
        String helpsetName = "help/help";
        try {
            ClassLoader cl = HelpTest.class.getClassLoader();
            URL url = HelpSet.findHelpSet(cl, helpsetName);
            mainHS = new HelpSet(cl, url);
        } catch (Exception ee) {
            System.out.println("Help Set " + helpsetName + " not found");
            return;
        } catch (ExceptionInInitializerError ex) {
            System.err.println("initialization error:");
            ex.getException().printStackTrace();
        }
        mainHB = mainHS.createHelpBroker();
        menuItem.addActionListener(new CSH.DisplayHelpFromSource(mainHB));
        menuItem.doClick();
    }
}
